package cn.maihe.elg.operation.repository.entity;

import cn.maihe.elg.operation.repository.entity.AcceptOrderContractVo;
import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_accept_order_contract")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.AcceptOrderContractMapper")
public class AcceptOrderContract extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 受理投保订单号
     */
    @TableField(value = "accept_order_no")
    private String acceptOrderNo;

    /**
     * 本地合同编号
     */
    @TableField(value = "local_contract_id")
    private String localContractId;

    /**
     * 渠道侧合同编号
     */
    @TableField(value = "channel_contract_id")
    private String channelContractId;

    /**
     * 合同名称
     */
    @TableField(value = "contract_name")
    private String contractName;

    /**
     * 合同状态；CREATED-已创建 SIGNING-签署中 REJECTED-已拒签 OVERDUE-已逾期  FINISHED-已完成
     */
    @TableField(value = "contract_status")
    private String contractStatus;

    /**
     * 合同起始日期
     */
    @TableField(value = "start_date")
    private Date startDate;

    /**
     * 合同终止日期
     */
    @TableField(value = "end_date")
    private Date endDate;

    /**
     * 合同类型 SQ:开立保函申请协议书 BH:担保保函书
     */
    @TableField(value = "contract_type")
    private String contractType;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    /**
     * 备注说明
     */
    @TableField(value = "remark")
    private String remark;

    public AcceptOrderContractVo buildVo() {
        return new AcceptOrderContractVo(id, acceptOrderNo, localContractId, channelContractId, contractName, contractStatus, startDate, endDate, contractType, gmtCreate, gmtModified, userCreate, userModified, remark);
    }

    public static AcceptOrderContract of(AcceptOrderContractVo vo) {
        return new AcceptOrderContract(vo.getId(), vo.getAcceptOrderNo(), vo.getLocalContractId(), vo.getChannelContractId(), vo.getContractName(), vo.getContractStatus(), vo.getStartDate(), vo.getEndDate(), vo.getContractType(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified(), vo.getRemark());
    }
}